/**
 * Created by Administrator on 2017/6/13.
 */
angular
    .module('myApp', [], function ($filterProvider, $provide, $controllerProvider) {
        // 配置

        $filterProvider.register('filterAge', function () {
            return function (obj) {
                return obj.sort(function (obj1, obj2) {
                    var val1 = obj1.age;
                    var val2 = obj2.age;
                    if (val1 < val2) {
                        return -1;
                    } else if (val1 > val2) {
                        return 1;
                    } else {
                        return 0;
                    }
                });
            }
        });
        $provide.service('Data', function () {
            return [
                {
                    name: 'zhumingyu',
                    age: 24
                },
                {
                    name: 'songyuqing',
                    age: 25
                },
                {
                    name: 'lijun',
                    age: 24
                },
                {
                    name: 'huranfeng',
                    age: 23
                }
            ];
        })

        $controllerProvider.register('MyController', function ($scope, Data) {
            $scope.names = Data;
        })
    });
// .controller('MyController',function ($scope,Data) {
//     $scope.names = Data;
//     console.log(Data)
// });